//
//  MineWebViewController.m
//  BabyAndBaby
//
//  Created by 范琦 on 16/8/2.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "MineWebViewController.h"
#import "MBProgressHUD.h"
#import "UIColor+YYAdd.h"

@interface MineWebViewController ()<UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation MineWebViewController
{

    MBProgressHUD *hud;
    
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tabBarController.tabBar.hidden = YES;
    [self creatHud];
    [self creatWebView];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden = NO;

}

- (void)creatWebView
{

    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT - 64)];
    NSURL *url =[NSURL URLWithString:_str];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
    _webView.delegate = self;
    [hud show:YES];
    [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(dismiss) userInfo:nil repeats:NO];
    
    
    
}
- (void)dismiss
{
    [hud hide:YES];
}
- (void)creatHud
{
    UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
    
    hud = [[MBProgressHUD alloc] initWithWindow:window];
    hud.removeFromSuperViewOnHide = YES;
    
    [window addSubview:hud];
    hud.labelText = @"数据正在加载中...";
    hud.labelColor = [UIColor colorWithHexString:@"#A1A1AC"];
    hud.labelFont = [UIFont systemFontOfSize:15];
    hud.mode = MBProgressHUDModeCustomView;
    hud.progress = 0;


}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"开始");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [hud hide:YES];
    NSLog(@"结束");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
{
    [hud hide:YES];

    NSLog(@"失败");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
